package xh.netty;

import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;



public class TcpServerHandler extends SimpleChannelInboundHandler<Object> {


    @Override
    public void channelRead0(ChannelHandlerContext ctx, Object msg) throws Exception {
        System.out.println("SERVER receive:"+msg);

        ctx.channel().writeAndFlush("yes, server is accepted you ,nice !" + msg);

        Thread.sleep(5 * 10 * 1000);

    }

    @Override
    public void exceptionCaught(ChannelHandlerContext ctx,
                                Throwable cause) throws Exception {
        System.out.println("Unexpected exception from downstream.");
        cause.printStackTrace();
        ctx.close();
    }
}